/*
 * RGBAColor.hpp
 */

#ifndef RGBACOLOR_HPP_
#define RGBACOLOR_HPP_

/**
 * Defines an RBGA color (RGB color with alpha-blending)
 * Color components are floating points between 0 and 1
 */
class RGBAColor {
public:
  /**
   * Constructor (default)
   */
  RGBAColor() {
    set(0., 0., 0., 1.);
  }

  /**
   * Constructor
   * @param r red channel of the RGBA Color
   * @param g green channel of the RGBA Color
   * @param b blue channel of the RGBA Color
   * @param a alphe channel (opacity) of the RGBA Color
   */
  RGBAColor(float r, float g, float b, float a) {
    set(r, g, b, a);
  }

  /**
   * Changes the channels of the RGBA Color
   * @param r red channel of the RGBA Color
   * @param g green channel of the RGBA Color
   * @param b blue channel of the RGBA Color
   * @param a alphe channel (opacity) of the RGBA Color
   */
  void set(float r, float g, float b, float a) {
    _red = r;
    _green = g;
    _blue = b;
    _alpha = a;
  }

  /**
   * Returns the inverse color computed for each channel such as : 1 - color_channel
   */
  RGBAColor getInverse() {
    return RGBAColor(1. - red(), 1. - green(), 1. - blue(), 1. - alpha());
  }

  /**
   * Returns the red channel
   */
  float red() {
    return _red;
  }

  /**
   * Returns the green channel
   */
  float green() {
    return _green;
  }

  /**
   * Returns the blue channel
   */
  float blue() {
    return _blue;
  }

  /**
   * Returns the alpha channel
   */
  float alpha() {
    return _alpha;
  }

private:
  /**
   * Color components
   */
  float _red;
  float _green;
  float _blue;
  float _alpha;
};

#endif /* RGBACOLOR_HPP_ */
